home *** CD-ROM | disk | FTP | other *** search
- Path: news.iadfw.net!usenet
- From: Larry Weiss <lfw@iadfw.net>
- Newsgroups: comp.lang.c
- Subject: Re: [Perf:] mem*() procs vs. array looping
- Date: Sat, 24 Feb 1996 14:12:46 -0600
- Organization: ---
- Message-ID: <312F713E.57E7@iadfw.net>
- References: <4glkq1$gu7@gazette.tandem.com>
- NNTP-Posting-Host: dal09-01.ppp.iadfw.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Francis E. Chang wrote:
- > Are mem*() procedures performance boosters? For example, for using
- > memcpy(tgt, src, length);
- > instead
- > for (index=0; index < length; index++)
- > tgt[i] = src[i];
-
-
- Issues of relative execution time of equivalent coded expressions are
- in the realm of "quality of implementation". There are no absolute
- answers for all implementations. One can discover by purely emperical
- evidence, or by evidence of inspection of the "machine language"
- generated by the compiler which expressions work better given a specific
- implementation, and then try to generalize to the most common finding,
- or embed conditional compilation (#if/#else/#endif) into your C code
- to emit the best for each implementation.
-
- A new version of a compiler (or choice of a selectable optimization
- strategy with the same compiler) may change the behaviour with
- respect to optimal code emitted.
-
- In any case, it's a fair assumption that the library's implementation is
- efficient, and should not be avoided on run-time performance grounds.
- With the new Standard, the compiler is allowed to generate inline machine
- instructions if it wants to to avoid the overhead of the function call
- for Standard library function calls.
-